package Test01;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
 
public class Test2 {  
 
public static void main(String[] srg) {  
 
   String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";   //加载JDBC驱动器
 
   String dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=TEST";   //连接服务器和数据库
 
   String userName = "poppyyjn";   //登录名 
 
   String userPwd = "123456";   //密码  
 
   Connection dbConn;  
   String sql = "insert into person values(?,?,?,?,?,?)";
   
   try {  
   
   Class.forName(driverName);  
 
   dbConn = DriverManager.getConnection(dbURL, userName, userPwd); 
   
   PreparedStatement pstmt = dbConn.prepareStatement(sql);
   pstmt.setString(1,"1");
   pstmt.setString(2,"1");
   pstmt.setString(3,"3");
   pstmt.setString(4,"3");
   pstmt.setString(5,"3");
   pstmt.setString(6,"3");
   pstmt.executeUpdate();
 
   System.out.println("Connection Successful!");   //登录成功
 
   } catch (Exception e) {  
 
   e.printStackTrace();  
 
   }  
 
}  
 
} 